<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="/WEB-INF/tlds/spring.tld"%>
<%@ taglib prefix="c" uri="/WEB-INF/tlds/c.tld"%>
<c:set var="BasePath" value="${pageContext.request.contextPath}"></c:set>
<c:set var="Plugins" value="${pageContext.request.contextPath}/res/plugins"></c:set>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>新增供应商</title>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/validate.css" media="screen"/>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/css.css" media="screen"/>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/style.css" media="screen"/>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/thickbox.css" media="screen"/>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/ui.datepicker.css" media="screen"/>
<link rev="stylesheet" rel="stylesheet" type="text/css" href="${BasePath}/res/css/common/ytsys-base.css" media="screen"/>
<link href="${Plugins}/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
<link href="${Plugins}/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
<script src="${Plugins}/jquery/jquery-1.4.4.min.js"	type="text/javascript"></script>
<script src="${Plugins}/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.validate.min.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/jquery.metadata.js" type="text/javascript"></script>
<script src="${Plugins}/jquery-validation/messages_cn.js" type="text/javascript"></script>
<script src="${BasePath}/res/js/common/jquery.form.js" type="text/javascript"></script>
<script type="text/javascript" src="${BasePath}/res/js/ligerCommon.js"></script>
<script src="${BasePath}/res/js/common/jquery.validate.method.js" type="text/javascript"></script>
<script src="${Plugins}/datepicker/WdatePicker.js" type="text/javascript"></script>
<style type="text/css">
    body{ font-size:14px;}
    .l-table-edit {}
    .l-table-edit-td{ padding:4px;}
    .l-button-submit,.l-button-test{width:80px; float:left; margin-left:10px; padding-bottom:2px;}
    .l-verify-tip{ left:230px; top:120px;}
    .p-tab .s-lab{font-size:14px;font-family:"微软雅黑",​"宋体",​Arial,​sans-serif;}
	input.l-textarea{width:170px;height:20px;font-size:14px;}
	.navbar {
		  height: 20px;
		  border-bottom: #E6E6E6 solid 1px;
		  line-height: 20px;
	     }
	.l-button-search {
	width: 50px;
	margin-left: 10px;
	padding-bottom: 2px;
	display: inline;
}
	.sort_select ul li img{ margin-left:0px;}
    .sort_select ul li{ margin-right: 20px;margin-top: 10px;padding:0 0;}
#choose_category_item_list, #choose_brand_items_list{ float:left}
#choose_category_item_list li, #choose_brand_items_list li, #control_vip_rank_catb2c_brand ul li{ display: inline-block;white-space: nowrap;width:250px;}
#choose_category_item_list li span, #control_vip_rank_catb2c_brand ul li span{ height:12px;line-height:12px;}
</style>

<script type="text/javascript">
//先隐藏
$(document).ready(function(){  
	$("#brand").hide();
	$("#category_brand").hide();
});

//显示与隐藏
$(function() {
	$("input[name=partakeType]").each(function(index) {
		$("input[name=partakeType]").eq(index).click(function() {
			switch (index) {
			case 0:
				$("#brand").show();
				$("#category_brand").hide();
				break;
			case 1:
				$("#category_brand").show();
				$("#brand").hide();
				break;
			default:
				break;
			}
		});
	});
})


//新增品牌
function addBrand(){
	var html = '';
	var brands = $(":checkbox[name='brand']:checked");
	if (brands.length == 0) {
		alert("请选择品牌");
		return;
	}
	var tmp_countter = 0;
	for(var i= 0 ;i < brands.length ; i++){
		if(brands[i].checked){
			var brandChkVal = brands[i].value.split(";");
		
			if(CHOOSE_Brand.indexOf(brandChkVal[1])==-1){
				//放入选择品牌列表-缓冲区
				CHOOSE_Brand.push(brandChkVal[1]);
				html += '<li id="choose_brand_item_'+brandChkVal[1]+'">'+brandChkVal[0]+'<input type="hidden" name="brandName" value="'+brandChkVal[0]+'"/> <input type="hidden" name="brandId" value="'+brandChkVal[1]+'"/><a href="javascript:delBrand(\''+brandChkVal[1]+'\');"><img alt="" src="${BasePath}/images/ylysystem/delete.gif"></a></li>';
				
				tmp_countter++
			}
		}
	}
	$("#choose_brand_items_list").append(html);
}

//删除品牌
function delBrand(id){
	$("#choose_brand_item_"+id).remove();
	CHOOSE_Brand = CHOOSE_Brand.del(CHOOSE_Brand.indexOf(id));
}
</script>
</head>
<body style="padding:10px">
<div class="navbar">
		<span>您当前的位置：</span>
	活动设置 &gt; 修改让利比例
</div>
<form name="form1" method="post" action="c_logisticInfo.do" id="form1">
<br>
<table cellpadding="0" cellspacing="0" class="l-table-edit p-tab" >
    <tr>
        <td align="right" class="l-table-edit-td s-lab"><font  color="red">*</font>活动名称:</td>
        <td align="left" class="l-table-edit-td s-lab"><input name="activityName"  type="text" class="l-textarea" disabled="disabled" id="activityName"  value="${activityInfo.activityName}" /></td>
        <td align="left"></td>
    </tr>
     <tr>
        <td align="right" class="l-table-edit-td s-lab"><font  color="red">*</font>活动编码:</td>
        <td align="left" class="l-table-edit-td s-lab"><input name="activityCode" type="text" class="l-textarea" disabled="disabled" id="activityCode"  value="${activityInfo.activityCode}" /></td>
        <td align="left"></td>
    </tr>
      <tr>
        <td align="right" class="l-table-edit-td s-lab"><font  color="red">*</font>参与商品:</td>
        <td align="left" class="l-table-edit-td s-lab">
         <select id="oneLevel" name="oneLevel">
        	<option value="0">顶级分类</option>
        	<c:forEach items="${commodityList}" var="item" >
        		<option value="${item.catNo }">${item.catName }</option>
        	</c:forEach>
        </select>
        <select id="twoLevel" name="twoLevel"> </select>
        <select id="threeLevel" name="threeLevel"></select>
        </td>
        <td align="left"></td>
    </tr>
    <tr>
        <td align="right" class="l-table-edit-td s-lab"></td>
        <td align="left" class="l-table-edit-td s-lab">
        <input name="partakeType" type="radio"  id="partakeType_0" value="0" />按品牌促销&nbsp;&nbsp;
        <input name="partakeType" type="radio"  id="partakeType_1" value="1" />按货品促销
        </td>
        <td align="left"></td>
    </tr>
    <br>
</table>
 <!--按品牌促销DIV-->
          <div id="brand">
             <div class="sort_select" id="choose_brand_container">
                   <p id="choose_brand_items">已选品牌</p>
                     <div>
                      <ul id="choose_brand_items_list"></ul>
                       <p class="clb" style="height:2px"></p>
                     </div>
           </div>
            <div id="control_vip_rank" style="display:none;">
                 <div class="blank10"></div>
                                               选择品牌分类 
                  <select id="commodityBrandSerie">
              <%-- <#if commodityBrandSeries??>
					<#list commodityBrandSeries as item>
                     <option value="${item.id}" selected="selected">${item.name}</option>
                     </#list>
                   </#if> --%>
                  </select>
             <div class="blank10"></div>
            </div>
          <div id="control_vip_ra">
          <div class="control_vip_ra_tt">
          <div class="blank10"></div>
          <span class="buytime">选择品牌&nbsp;&nbsp;&nbsp;&nbsp;</span>
          <span class="operate"><a href="javascript:pp_select(1);">全选</a><a href="javascript:pp_select(2);">反选</a></span>
          <div class="blank10"></div>
          </div>
          <div class="control_vip_ra" id="brands_container"> </div>
         </div>
         <div class="blank15"></div>
           <input type="button" value="添加品牌" class="l-button l-button-submit" onclick="addBrand();">
        </div>
        
 <!--按货品促销DIV-->
       <div id="category_brand">
            <div class="sort_select" id="control_vip_rank_catb2c_brand"></div>
             <div id="control_vip_rank">
                 <div class="blank10"></div>
                货品编码：<input type="text" name="gNo" id="gNo" value="">&nbsp;&nbsp;&nbsp;&nbsp;
             商品名称：<input type="text" name="cName" id="cName" value="">&nbsp;&nbsp;&nbsp;&nbsp;
                <input id="btnOK" type="submit" value="查询" class="l-button-search" />
                <div class="blank10"></div>
             </div>
             <div id="choose_brand_catb2cs_container"></div>
             <div class="blank15"></div>
             <input type="button"  onclick="addBrandCatb2c()" value="添加货品" class="l-button l-button-submit">
        </div>
       <p class="clb"></p>
<input type="submit" value="保存" id="Button1" class="l-button l-button-submit" /> 
<input type="button" value="取消" name="tests"  id="tests" class="l-button l-button-test" />
</form>
<div style="display:none">
<!--  数据统计代码 --></div> 

<script type="text/javascript">
var basePath="${BasePath}";
$(function() {
	$("#twoLevel").hide();
	$("#threeLevel").hide();
	$("select").each(function(index) {
		$("select").eq(index).change(function(){
			var no = $("select").eq(index).val();
			
			if(no == '0' || no == ''){
				$("select").each(function(i) {
					$("select").eq(i+1).hide();
				});
			}else{
				$("select").eq(index+1).empty();
				$("select").eq(index+1).show();
				
				var m = "<option value=''>请选择</option>";
				$.post(basePath + '/product/cat/getAjaxNextCommodityCat.do', {
					catPno : no
				}, function(data) {
					if(data != ""){
						var obj=$.parseJSON(data);
						for(var i in obj){
							 m+="<option value=' "+obj[i].catNo+"'>"+obj[i].catName+" </option>"; 
						 };
					};
				});
				$("select").eq(index+1).append(m);
			};
		});
	});
});

$(function ()
		{
			//validate
		    $.metadata.setType("attr", "validate");
		    var v = $("form").validate({
		        errorPlacement: function (lable, element)
		        {
		        	lable.ligerHideTip();
		            if (element.hasClass("l-textarea"))
		            {
		                element.ligerTip({ content: lable.html(), target: element[0] }); 
		            }
		            else if (element.hasClass("l-text-field"))
		            {
		                element.parent().ligerTip({ content: lable.html(), target: element[0] });
		            }
		            else
		            {
		                lable.appendTo(element.parents("td:first").next("td"));
		            }
		        }
		    ,
		        success: function (lable)
		        {
		            lable.ligerHideTip();
		            lable.remove();
		        },
		        submitHandler:function()
		        {
		            $("form .l-text,.l-textarea").ligerHideTip();
		            var options = {
		            		type: 'POST',
		            		beforeSend: function(){
		            			$("#form1").find(":submit,:button").attr("disabled", true);
		            		},
		            		success: function(data){
		            			if(data=="success") {
		            				window.parent.f_tip('新增成功');
		            				window.location.href="../../base/logisticsManageController/toPageFinderLogisticInfo.do";
		           					close_liger_tab();
		            			} else {
		            				window.parent.f_tip('新增失败');
		            			}
		            		}
		            	}, $form1 = $("#form1");
		           $form1.ajaxSubmit(options);
		             return false;
		        }
		    });
		}); 
// 取消
$("#tests").click(function() {
	close_liger_tab();
});	
</script>
</body>
</html>